package com.dongdongshop.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dongdongshop.constant.HttpResultEnum;
import com.dongdongshop.data.DataResult;
import com.dongdongshop.pojo.itemCat.TbItemCat;
import com.dongdongshop.pojo.typeTemplate.TbTypeTemplate;
import com.dongdongshop.service.typeTemplate.TypeTemplateService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author Eayon
 * @Date 2020/2/28 10:17
 */
@Controller
@RequestMapping("typeTemplate")
public class TypeTemplateController {
    private Logger log = LoggerFactory.getLogger(TypeTemplateController.class);

    @Reference
    private TypeTemplateService typeTemplateService;

    /**
     * 根据模板id查询模板信息
     * @param id
     * @return
     */
    @RequestMapping(value = "getTypeTemplateById",method = RequestMethod.POST)
    @ResponseBody
    public DataResult getTypeTemplateById(Long id){
        TbTypeTemplate tt = null;
        try {
            tt = typeTemplateService.getTypeTemplateById(id);
        }catch (Exception e){
            log.error("根据模板id查询模板信息异常",e);
            return new DataResult(HttpResultEnum.ERROR.getCode(),HttpResultEnum.ERROR.getMessage());
        }
        return new DataResult(HttpResultEnum.SUCCESS.getCode(),HttpResultEnum.SUCCESS.getMessage(),tt);
    }
}
